unit RandomGenerate;

{$mode ObjFPC}{$H+}

interface

uses
  Classes, SysUtils, Forms, Controls, ExtCtrls, StdCtrls, EditBtn, DevToysPlugin;

type
  TRandomGenerate = class(TInterfacedObject, IDevToysPlugin)
    FPanel: TPanel;
    FEditIn, FEditOut: TMemo;
    FBtn: TButton;
    procedure BtnClick(Sender: TObject);
  public
    function Title: string;
    function Description: string;
    procedure BuildUI(Parent: TWinControl);
    procedure Cleanup;

    //class procedure RegisterPlugin(Reg: TRegisterProc); static;  // 类方法
  end;

procedure RegisterPlugin(Reg: TRegisterProc);

implementation

procedure RegisterPlugin(Reg: TRegisterProc);
begin
  Reg(TRandomGenerate.Create);
end;

function TRandomGenerate.Title: string;
begin
  Result := '生成随机字符';
end;

function TRandomGenerate.Description: string;
begin
  Result := '生成随机字符';
end;

procedure TRandomGenerate.BuildUI(Parent: TWinControl);
begin
  FPanel := TPanel.Create(Parent);
  FPanel.Parent := Parent;
  FPanel.Align := alClient;
  FPanel.BevelOuter := bvNone;

  FEditIn := TMemo.Create(FPanel);
  FEditIn.Parent := FPanel;
  FEditIn.Align := alTop;
  FEditIn.Height := 120;
  FEditIn.Text := 'Type something';

  FBtn := TButton.Create(FPanel);
  FBtn.Parent := FPanel;
  FBtn.Top := FEditIn.Height + 8;
  FBtn.Caption := '生成';
  FBtn.OnClick := @BtnClick;

  FEditOut := TMemo.Create(FPanel);
  FEditOut.Parent := FPanel;
  FEditOut.Align := alBottom;
  FEditOut.Height := 120;
  FEditOut.ReadOnly := True;
end;

procedure TRandomGenerate.BtnClick(Sender: TObject);
begin
end;

procedure TRandomGenerate.Cleanup;
begin
  FPanel.Free;
end;

end.
